﻿using Microsoft.Xna.Framework;

namespace Babylon.Primitives
{
    /// <summary>
    /// textured ellipse with tangent info
    /// </summary>
    public class TexturedEllipseWithTangents: EllipseBase<VertexPositionNormalTextureTangent>
    {
        public TexturedEllipseWithTangents(float verticalRay, float horizontalRay, int verticalSubdivisions)
            : base(verticalRay, horizontalRay, verticalSubdivisions)
        {
        }
        protected override void BeforeCreatingVertices(float horizontalRay, float verticalRay, int subdivisions)
        {
        }

        protected override void AfterCreatingVertex(ref VertexPositionNormalTextureTangent vertex, float normalizedZRot, float normalizedYRot)
        {
            vertex.TexCoords = new Vector2(normalizedYRot, normalizedZRot);

            var rotY = Matrix.CreateRotationY(normalizedYRot * 2 * MathHelper.Pi);
            vertex.Tangent = Vector3.Transform(Vector3.Forward, rotY);
        }

        protected override VertexPositionNormalTextureTangent CreateVertex()
        {
            return new VertexPositionNormalTextureTangent();
        }

        protected override Microsoft.Xna.Framework.Graphics.VertexDeclaration GetVertexDeclaration()
        {
            return VertexPositionNormalTextureTangent.GetVertexDeclaration();
        }
    }
}
